package com.xing.async;

/**
 * SCHD_ASYNC_FINISH:异步消息IO部分结束,进行收尾操作
 *
 */
public class InternalMsgHandler<T extends Sender> implements IMessageHandler<ISenderMessage<T>> {

	/** 可处理的消息类型列表 */
	private static final short[] TYPE_LIST = { MessageType.SCHD_REPORT_TO_WS_TIMER, MessageType.SCHD_ASYNC_FINISH };

	@Override
	public void execute(ISenderMessage<T> message) {
		if (!(message.getSender() instanceof InternalSender)) {
			throw new IllegalStateException("Only internal msg shuod be processed.");
		}
		switch (message.getType()) {
		case MessageType.SCHD_REPORT_TO_WS_TIMER:
			//Services.getWorldServerManager().reportStatus();
			break;
		case MessageType.SCHD_ASYNC_FINISH:
			ScheduleAsyncFinishMessage _msg = (ScheduleAsyncFinishMessage) message;
			_msg.getOperation().execute();
			break;
		}
	}

	@Override
	public short[] getTypes() {
		return TYPE_LIST;
	}
}
